/***************************************************************************/
/*********     This comment should be filled with a description    *********/
/*********         of your program and what it does.               *********/
/*********       This template is for Botball programs.            *********/
/*********    Make sure you have selected the CBC target.          *********/
/***************************************************************************/

/* Libraries used in Botball are automatically included, but list any additional includes here */

/* #defines and constants go here.*/
#define clawlengthinseconds=5;
/*Global variables go here (if you absolutely need them).*/

/*Function prototypes below*/
int placeincenter()
{
	set_servo_position(OPEN_CLOSE, OPEN);
	set_servo_poistion(UP_DOWN, DOWN);
	move_at_velocity(motorleft, 500);
	move_at_velocity(motorright, 500);
	sleep(clawlengthinseconds);
	move_at_velocity(motorright, 0);
	move_at_velocity(motorleft, 0);
	set_servo_position(OPEN_CLOSE, CLOSE);
	sleep(.5);
	set_servo_position(UP_DOWN, UP);
	move_at_velocity(motorright, 500);
	move_at_velocity(motorleft, 500);
	sleep(clawlengthinseconds);
	set_servo_position(UP_DOWN, DOWN);
	set_servo_position(OPEN_CLOSE, OPEN);
	sleep(.5);
	set_servo_position(UP_DOWN, UP);
	set_servo_position(OPEN_CLOSE, CLOSE);
}

int backuptinybit()
{
	int timebackup=2; // time needed to move back to have space for turn
	move_at_velocity(motorright, -500);
	move_at_velocity(motorleft, -500);
	sleep(timebackup);
}

int gountilbothtouch()
{
	move_at_velocity(0, 500);
	move_at_velocity(3, 500);
	while(!digital(9)=1 || !digital(10)=1)
	{sleep(0.02);}
}
int oilyducks()
{
	 //time backing up needed to have room for claw
	int distanceinseconds=5; // time needed for distance between two top oil slicks
	set_servo_position(OPEN_CLOSE, CLOSE);
	set_servo_position(UP_DOWN, UP);
	turnright(180);
	
	gountilbothtouch();
	backuptinybit();
	turnright(90);
	gountilbothtouch();
	backuptinybit()
	turnright(90);
	move_at_velocity(motorright, 500);
	move_at_velocity(motorleft, 500);
	sleep(distanceinseconds);
	turnright(90);
	gountilbothtouch();
	move_at_velocity(motorleft, -500);
	move_at_velocity(motorright, -500);
	sleep(clawlengthinseconds);
	turnright(180);
		placeincenter();
int main()
{
	oilyducks()
    /*//All variable declarations go here.
    
    //This is your main function.
    
    //Wait for starting light with light sensor in the_port_number
        wait_for_light(the_port_number);
        
    //Run your_code for the amount_of_time
        run_for(amount_of_time, your_code);
        
    //Make sure your motors are stopped
        ao();
        create_stop();
        
    //Put anything below you want your robot to do after the game (e.g. play victory song).
    */
}

/*Declare functions here as needed.*/
